<?php
require_once MODEL_DIR .'/Person.php';

class MainAddPresenter extends Presenter {
	
	public function Setup() {
		$this->view->Set('JSONRPC_URL', Dispatch::GetURL(array('page' => 'JSONRPC')));
	}
	
    public function HandleAddButtonClicked($values) {
        if (!$this->view->form->validate()) {
            return false;
        }
        
        $person = new Person;
        $person->firstName = $values['firstName'];
        $person->lastName  = $values['lastName'];
        $person->gender    = $values['gender'];
        $person->birthDate = $values['birthDate']['Y'] .'-'. $values['birthDate']['M'] .'-'. $values['birthDate']['d'];
        $person->deathDate = $values['deathDate']['Y'] .'-'. $values['deathDate']['M'] .'-'. $values['deathDate']['d'];

        $person->Save();
    }
}

?>